package com.example.analysis.controller;

import com.example.analysis.entity.Course;
import com.example.analysis.entity.Teacher;
import com.example.analysis.service.ElectionListService;
import com.example.analysis.vo.ResponseVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/analysis_grade")
public class ElectionListController {
    @Resource
    private ElectionListService electionListService;

    @GetMapping("/insert")
    String insert() {
        electionListService.insert();
        return "hello world";
    }

    @GetMapping("/normality")
    ResponseVO<String> normality(String courseId, String classId, String teacherId) {
        electionListService.normalityTest(courseId, classId, teacherId);
        return ResponseVO.success("hello world");
    }

    @GetMapping("/discrimination_analysis")
    String discriminationAnalysis(String courseId, String classId, String teacherId) {
        electionListService.discriminationAnalysis(courseId, classId, teacherId);
        return "hello world";
    }

    @GetMapping("/class_grade_difference")
    String gradeDifference(String courseId, String classId, String teacherId) {
        System.out.println(courseId +", "+classId+", "+teacherId);
        electionListService.courseGradeAnalysis(courseId, classId, teacherId);
        return "hello world";
    }

    // 查课程
    @GetMapping("/courses")
    ResponseVO<List<Course>> getCourses() {
        List<Course> courses = electionListService.getCourses();
        return ResponseVO.success(courses);
    }
    // 查教师
    @GetMapping("/teachers")
    ResponseVO<List<Teacher>> getTeachers(String courseId) {
        List<Teacher> teachers = electionListService.getTeachers(courseId);
        return ResponseVO.success(teachers);
    }
}
